<template>
	<div class="mainContent">
		<pathTracking :path="Model.path" />
		<div class="container">
			<!-- 一级tabs -->
			<el-tabs v-model="Model.activeTab" @tab-click="onTabChange">
				<el-tab-pane label="采购入库单" name="1"></el-tab-pane>
				<el-tab-pane label="操作记录" name="2"></el-tab-pane>
			</el-tabs>
			<div class="tabBox">
				<div class="tabBoxStep">
					<el-steps :active="Model.stepOption.activeStep">
						<el-step :title="item.title" :description="item.description" v-for="(item,index) in Model.stepOption.step" :key="index"></el-step>
					</el-steps>
				</div>
				<el-row class="detailTable">
					<el-form :inline="true">
						<el-col :sm="24" :md="12" :lg="8" :xl="6" v-for="(item,index) in Model.tabFormInline" :key="index">
							<el-form-item :label="item.label+'：'">{{item.value}}</el-form-item>
						</el-col>
					</el-form>
				</el-row>
				<el-row class="detailTable">
					<div class="detailTableItemTitle">
						<span class="detailTableImgSmall"></span>
						<p class="text">采购单基础信息</p>
						<img class="detailTableImgNormal" src="@/assets/img/icon_edit.png" @click="onDialogEdit(true,'tableFormInline')">
						<img class="detailTableImgNormal" :src="Model.detailTableFrom.src" alt="" @click="toggleTableDetail('detailTableFrom')">
					</div>
					<el-form :inline="true" v-show="Model.detailTableFrom.flag">
						<el-col :sm="24" :md="12" :lg="8" :xl="6" v-for="(item,index) in Model.tableFormInline" :key="index">
							<el-form-item :label="item.label+'：'">{{item.value}}</el-form-item>
						</el-col>
					</el-form>
				</el-row>
				<div v-show="Model.activeTab==1">
					<el-row class="detailTable">
						<div class="detailTableItemTitle">
							<span class="detailTableImgSmall"></span>
							<p class="text">商品明细-应入</p>
							<img class="detailTableImgNormal" :src="Model.tab1TableDetail1.src" alt="" @click="toggleTableDetail('tab1TableDetail1')">
							<!-- <img class="detailTableImgNormal" src="@/assets/img/icon_unfold.png" alt="" v-show="Model.tab1TableDetail1"> -->
						</div>
						<div class="detailTableDetail" v-show="Model.tab1TableDetail1.flag">
							<el-table :data="Model.tableData" border style="width: 100%;max-height:550px">
								<el-table-column type="index" width="50" label="序号" fixed></el-table-column>
								<el-table-column prop="customNumber" label="商品图片" width="100"></el-table-column>
								<el-table-column prop="goodType" label="采购订单号" width="120"></el-table-column>
								<el-table-column prop="category" label="采购订单行项目号" width="150"></el-table-column>
								<el-table-column prop="lettering" label="商品编码" width="120"></el-table-column>
								<el-table-column prop="barCode" label="条码" width="200"></el-table-column>
								<el-table-column prop="price" label="款式" width="120"></el-table-column>
								<el-table-column prop="specialCustom" label="品类" width="120"></el-table-column>
								<el-table-column prop="description" width="150">
									<template slot="header" slot-scope="scope">
										<el-tooltip content="钻石信息顺序:颜色-净度-切工-抛光-对称-荧光" placement="top">
											<span class="iconQuestionmark">描述</span>
										</el-tooltip>
									</template>
								</el-table-column>
								<el-table-column prop="remark" label="数量" width="120"></el-table-column>
								<el-table-column prop="mainCount" label="单位" width="120"></el-table-column>
								<el-table-column prop="mainCount1" label="备注" width="120"></el-table-column>
							</el-table>
						</div>
					</el-row>
					<el-row class="detailTable">
						<div class="detailTableItemTitle">
							<span class="detailTableImgSmall"></span>
							<p class="text">商品明细-实入</p>
						</div>
						<div class="detailTableDetail">
							<div class="exportBox">
								<div class="exportBoxAuto">
									<span>是否手动导入</span>
									<el-radio-group v-model="Model.exportBarcodeFlag">
										<el-radio :label="false">否</el-radio>
										<el-radio :label="true">是</el-radio>
									</el-radio-group>
									<button v-show="Model.exportBarcodeFlag">导入物料</button>
									<button @click="onDeleteExportData">删除</button>
								</div>
								<div class="exportBoxHand" v-show="!Model.exportBarcodeFlag">
									<el-input v-model="Model.exportBarcode" placeholder="请输入条码/包码/物料编码"></el-input>
									<button>确认</button>
								</div>
							</div>
							<el-table :data="Model.tableData" border style="width: 100%;max-height:550px" @selection-change="onTableSelectionChange">
								<el-table-column type="selection" width="50" fixed></el-table-column>
								<el-table-column type="index" width="50" label="序号" fixed></el-table-column>
								<el-table-column prop="customNumber" label="商品图片" width="100"></el-table-column>
								<el-table-column prop="cangku" label="入库仓库" width="100"></el-table-column>
								<el-table-column prop="goodType" label="采购订单号" width="120"></el-table-column>
								<el-table-column prop="category" label="采购订单行项目号" width="150"></el-table-column>
								<el-table-column prop="lettering" label="商品编码" width="120"></el-table-column>
								<el-table-column prop="originId" label="条码" width="130">
									<template slot-scope="scope">
										<el-button type="text" @click="toBarcodeDetail(scope.row)">{{scope.row.originId}}</el-button>
									</template>
								</el-table-column>
								<el-table-column prop="price" label="款式" width="120"></el-table-column>
								<el-table-column prop="specialCustom" label="品类" width="120"></el-table-column>
								<el-table-column prop="description" width="150">
									<template slot="header" slot-scope="scope">
										<el-tooltip content="钻石信息顺序:颜色-净度-切工-抛光-对称-荧光" placement="top">
											<span class="iconQuestionmark">描述</span>
										</el-tooltip>
									</template>
								</el-table-column>
								<el-table-column prop="remark" label="数量" width="120"></el-table-column>
								<el-table-column prop="mainCount" label="单位" width="120"></el-table-column>
								<el-table-column prop="mainCount1" label="备注" width="120"></el-table-column>
							</el-table>
						</div>
						<div>
							<button>确认</button><button>取消</button>
						</div>
					</el-row>

				</div>
				<div v-show="Model.activeTab==2">
					<el-row class="detailTable">
						<div class="detailTableItemTitle">
							<span class="detailTableImgSmall"></span>
							<p class="text">订单操作日志</p>
							<img class="detailTableImgNormal" :src="Model.tab2TableDetail1.src" alt="" @click="toggleTableDetail('tab2TableDetail1')">
						</div>
						<div class="detailTableDetail" v-show="Model.tab2TableDetail1.flag">
							<el-table :data="Model.saleLogList" border show-summary style="width: 100%;max-height:550px" @selection-change="onTableSelectionChange">
								<el-table-column prop="createTime" label="时间" width="200"></el-table-column>
								<el-table-column prop="type" label="操作类型" width="120"></el-table-column>
								<el-table-column prop="createBy" label="操作人" width="120"></el-table-column>
								<el-table-column prop="record" label="操作记录"></el-table-column>
							</el-table>
						</div>
					</el-row>
				</div>
			</div>
		</div>
		<!-- 弹框 -->
		<el-dialog :visible.sync="Model.editDialogFlag" top="100px" class="viewDialog">
			<div class="common-table-title">
				<div class="common-table-icon"></div>
				<div class="common-table-fl">编辑</div>
			</div>
			<div style="padding:30px;background: #fff;">
				<div class="editDialogItem">
					<div class="editDialogLeftLabel">
						<span class="editDialogRequire">*</span>配送类型：
					</div>
					<div class="editDialogRightText">
						<el-select v-model="Model.editDialogFormData.shippingMethod" placeholder="请选择" size="small">
							<el-option label="自提" value="1"></el-option>
							<el-option label="快递" value="0"></el-option>
						</el-select>
					</div>
				</div>
				<div class="editDialogItem" v-show="Model.editDialogFormData.shippingMethod=='1'">
					<div class="editDialogLeftLabel">
						<span class="editDialogRequire">*</span>发货门店：
					</div>
					<div class="editDialogRightText">
						<el-select v-model="Model.editDialogFormData.shipper" placeholder="请选择" size="small">
							<el-option label="天猫" value="0"></el-option>
							<el-option label="京东" value="1"></el-option>
						</el-select>
					</div>
				</div>
				<div class="editDialogItem">
					<div class="editDialogLeftLabel">
						<span class="editDialogRequire">*</span>销售来源：
					</div>
					<div class="editDialogRightText">
						<el-select v-model="Model.editDialogFormData.originChannel" placeholder="请选择" size="small">
							<el-option label="dr1002" value="0"></el-option>
							<el-option label="dr2003" value="1"></el-option>
						</el-select>
					</div>
				</div>
				<div class="editDialogItem">
					<div class="editDialogLeftLabel">
						<span class="editDialogRequire">*</span>销售员：
					</div>
					<div class="editDialogRightText">
						<el-select v-model="Model.editDialogFormData.salesman" placeholder="请选择" size="small">
							<el-option label="张三" value="0"></el-option>
							<el-option label="李四" value="1"></el-option>
						</el-select>
					</div>
				</div>
				<div class="editDialogItem" v-show="Model.editDialogFormData.shippingMethod=='0'">
					<div class="editDialogLeftLabel">
						是否新建地址：
					</div>
					<div class="editDialogRightText">
						<el-radio-group v-model="Model.editDialogNewAddress" @change="changeAddress">
							<el-radio :label="true">是</el-radio>
							<el-radio :label="false">否</el-radio>
						</el-radio-group>
					</div>
				</div>
				<div v-if="Model.editDialogNewAddress&&Model.editDialogFormData.shippingMethod=='0'">
					<div class="editDialogItem">
						<div class="editDialogLeftLabel">
							<span class="editDialogRequire">*</span>收件人姓名：
						</div>
						<div class="editDialogRightText">
							<el-input v-model="Model.editDialogFormData.recipientName" placeholder="请输入内容"></el-input>
						</div>
					</div>
					<div class="editDialogItem">
						<div class="editDialogLeftLabel">
							<span class="editDialogRequire">*</span>收件人手机号：
						</div>
						<div class="editDialogRightText">
							<el-input v-model="Model.editDialogFormData.recipientPhone" placeholder="请输入内容"></el-input>
						</div>
					</div>
					<div class="editDialogItem">
						<div class="editDialogLeftLabel">
							<span class="editDialogRequire">*</span>短信通知手机：
						</div>
						<div class="editDialogRightText">
							<el-input v-model="Model.editDialogFormData.messagePhone" placeholder="请输入内容"></el-input>
						</div>
					</div>
					<div class="editDialogItem">
						<div class="editDialogLeftLabel">
							收货地址类型：
						</div>
						<div class="editDialogRightText">
							<el-radio-group v-model="Model.editDialogFormData.addressType">
								<el-radio label="大陆" value="0"></el-radio>
								<el-radio label="海外" value="1"></el-radio>
							</el-radio-group>
						</div>
					</div>
					<div class="editDialogItem">
						<div class="editDialogLeftLabel">
							<span class="editDialogRequire">*</span>收货人所在地区：
						</div>
						<div class="editDialogRightText">
							<el-input v-model="Model.editDialogFormData.location" placeholder="请输入内容"></el-input>
						</div>
					</div>
					<div class="editDialogItem">
						<div class="editDialogLeftLabel">
							<span class="editDialogRequire">*</span>收货人详细地址：
						</div>
						<div class="editDialogRightText">
							<el-input v-model="Model.editDialogFormData.detailedAddress" placeholder="请输入内容"></el-input>
						</div>
					</div>
				</div>
				<div class="viewDialogFooter">
					<div class="viewDialogFooterSure" @click="updateBaseSaleOrder">
						保存
					</div>
					<div class="viewDialogFooterCancel" @click="onDialogEdit(false,'tableFormInline')">
						取消
					</div>
				</div>
			</div>
		</el-dialog>

	</div>
</template>

<script>
	import pathTracking from "@/components/common/pathTracking";
	import pagination from "@/components/common/pagination.vue";
	import advancedSearch from "@/components/common/filter/advancedSearch";
	import {
		getDateString
	} from "@/assets/js/common.js";
	import Model from "./model.js";
	import Controller from "./controller.js";
	export default {
		name: "purchase",
		mixins: [Model, Controller],
		components: {
			advancedSearch,
			pagination,
			pathTracking
		}
	};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
	@import "./index.less";
</style>
